package com.gblfy.api.factory;

import com.gblfy.api.RemoteProductService;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * 产品服务降级处理
 *
 * @author gblfy
 */
@Component
public class RemoteProductFallbackFactory implements FallbackFactory<RemoteProductService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteProductFallbackFactory.class);

    @Override
    public RemoteProductService create(Throwable throwable) {
        log.error("用户服务调用失败:{}", throwable.getMessage());
        return new RemoteProductService() {

            @Override
            public String getProductName(Integer productId) {
                return "获取产品名称失败";
                // return R.fail("获取产品名称失败:" + throwable.getMessage());
            }
        };
    }
}
